<template>
  <el-dialog custom-class="app_dialog" v-model="props.appDialog.visible" :width="props.appDialog.width" :before-close="handleClose">
    <template #title>
      <div class="dialog_header">{{ props.appDialog.title }}</div>
    </template>
    <section>
      <slot></slot>
    </section>
    <template #footer>
      <span class="dialog_footer">
        <el-button v-if="props.appDialog.cancel" class="ml20" @click="props.appDialog.cancel">{{ props.appDialog.cancelText }}</el-button>
        <el-button v-if="props.appDialog.save" class="ml20" plain @click="props.appDialog.save">{{ props.appDialog.saveText }}</el-button>
        <!-- 本地上传 -->
        <template v-if="props.appDialog.uploadShow">
          <el-upload class="upload_demo" :on-change="handleChange" :file-list="fileList">
            <el-button type="primary" plain>本地上传</el-button>
          </el-upload>
          <!-- <ZWUpload ref="ZWUploadRef" :upInfo="props.appDialog.upInfo" @submit="upload" /> -->
        </template>

        <el-button v-if="props.appDialog.submit" :disabled="appDialog.isDisable" class="ml20" type="primary" @click="props.appDialog.submit">{{ props.appDialog.submitText }}</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
interface Props {
  width?: '30%'
  visible: boolean
  title: string
  uploadShow?: boolean
  cancelText?: string
  saveText?: string
  submitText?: string
  isDisable?: boolean
  cancel?: () => void
  save?: () => void
  submit?: () => void
}
const props = defineProps<{
  appDialog: {
    type: Props
    required: true
  }
}>()

const handleClose = (done: () => void) => {
  props.appDialog.cancel && props.appDialog.cancel()
  done()
}

const upload = (val: any) => {}
</script>
